package com.bd.rj.frontstage.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bd.rj.frontstage.service.impl.EnterpriseServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/enterprise")
public class EnterpriseController {
    @Resource
    private EnterpriseServiceImpl enterpriseService;

    /**
     * 根据企业名称获取企业id
     * @author WBW
     * @param ename  企业的ID
     * @return
     */
    @GetMapping("getenterpriseid")
    public Map<String, Object> getEnterpriseList(String ename) {
        Map<String, Object> map = new HashMap<>();
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.select("id").eq("ename", ename);
        map.put("msg", "success");
        map.put("code", 200);
        map.put("data", enterpriseService.listObjs(wrapper));
        return map;
    }

    /**
     * 查询企业名称
     * @author WBW
     * @return
     */
//    @GetMapping("getename")
//    public Map<String, Object> getEname() {
//        Map<String, Object> map = new HashMap<>();
//        QueryWrapper wrapper = new QueryWrapper();
//        wrapper.select("ename");
//        map.put("msg", "success");
//        map.put("code", 200);
//        map.put("data", enterpriseService.listObjs(wrapper));
//        return map;
//    }

    /**
     * @desc 根据岗位表中的企业id查询企业电话
     * @author yxh
     * @param eid
     * @return
     */
   @GetMapping("/querybyid")
   public Map<String, Object> getEnterpriseById(Long eid) {
       Map<String, Object> map = new HashMap<>();
       List<String> phoneNumbers = enterpriseService.getDistinctPhonesByEid(eid);
       map.put("msg", "success");
       map.put("code", 200);
       map.put("data", phoneNumbers);
       return map;
   }
}
